<include file="Public/header" title="处理留言" />
<div id="page-wrapper">
    <form method="post" action="{:U('message/update')}" enctype="multipart/form-data">
        <input type="hidden" name="message_id" value="{$info.id}">
        <div class="form-group">
            <label for="aa">姓名</label>
            <input type="text" name="title" class="form-control"  readonly="readonly"  value="{$info.name}">
        </div>
        <div class="form-group">
            <label for="aa">手机</label>
            <input type="text" name="title" class="form-control" readonly="readonly"  value="{$info.mobile}">
        </div>
        <div class="form-group">
            <label for="aa">邮箱</label>
            <input type="text" name="title" class="form-control" readonly="readonly"  value="{$info.email}">
        </div>
        <div class="form-group">
            <label for="aa">公司</label>
            <input type="text" name="title" class="form-control"  readonly="readonly"   value="{$info.company}">
        </div>
        <div class="form-group">
            <label for="aa">留言</label>
            <textarea type="text" class="form-control"  readonly="readonly" >{$info.message}</textarea>
        </div>

        <div class="form-group">
            <label>状态</label>
            <label class="radio-inline">
                <input type="radio" name="status" id="status" value="-1">删除
            </label>
            <label class="radio-inline">
                <input type="radio" name="status" id="status" value="0" <if condition="$info[status] eq 0"> checked="checked" </if>>未处理
            </label>
            <label class="radio-inline">
                <input type="radio" name="status" id="status" value="1" <if condition="$info[status] eq 1"> checked="checked" </if>>已处理
            </label>
        </div>
        <button type="submit" class="btn btn-primary">提交</button>
        <a href="{:U('message/index')}" class="btn btn-default">返回列表</a>
    </form>
</div>
<script type="text/javascript">
    function imgPreview(fileDom){
        //判断是否支持FileReader
        if (window.FileReader) {
            var reader = new FileReader();
        } else {
            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
        }

        //获取文件
        var file = fileDom.files[0];
        var imageType = /^image\//;
        //是否是图片
        if (!imageType.test(file.type)) {
            alert("请选择图片！");
            return;
        }
        //读取完成
        reader.onload = function(e) {
            //获取图片dom
            var img = document.getElementById("preview");
            //图片路径设置为读取的图片
            img.src = e.target.result;
        };
        reader.readAsDataURL(file);
    }
    function upload() {
        var xhr = new XMLHttpRequest();
        var progress = document.getElementById("progress")
        progress.style.display = "block";

        xhr.upload.addEventListener("progress", function(e) {
            if (e.lengthComputable) {
                var percentage = Math.round((e.loaded * 100) / e.total);
                progress.value = percentage;
            }
        }, false);

        xhr.upload.addEventListener("load", function(e){
            console.log("上传完毕...")
        }, false);

        xhr.open("POST", "upload");
        xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                alert(xhr.responseText); // handle response.
                progress.style.display = "none";
                progress.value = 0;
            }
        };
        var file = document.getElementById("imgFile");
        var fd = new FormData();
        fd.append(file.files[0].name, file.files[0]);
        xhr.send(fd);
    }
</script>

<include file="Public/footer" />